home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS09.ADF
/
AmigaBasicProgs
/
Requester
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-05-22
|
2KB
|
82 lines
SUB req(line1$,line2$,w%,s%,ans%) STATIC
'--------------------------------------------
' AmigaBASIC requester subroutine
'
' J. S. Plegge 14-Feb-1986
'
' Based on an article by Tom R. Halfhill
' in the March 86 Compute!
'
' Parameters:
' line1$ - 1st line of requester text
' line2$ - 2nd line of requester text
' w% ----- window id number
' s% ----- screen id number (0 for current)
' ans% --- return parm;
' true for OK, false for Cancel
'--------------------------------------------
cols= 80: ' Change to 60 for 60-col prefs
true= -1: false=0: dunno=1
okx1= 12: okx2= 50: oky1=20: oky2=38: ' x,y coords of OK
cnx1=152: cnx2=228: cny1=20: cny2=38: ' x,y coords of Cancel
IF s%=0 THEN
WINDOW w%,"Program Request",(0,0)-(311,45),16
ELSE
WINDOW w%,"Program Request",(0,0)-(311,45),16,s%
END IF
COLOR 0,1: ' blue on white
PRINT CHR$(12);: ' clear window
IF cols=80 THEN
maxlen=INT(WINDOW(w%)/8)
ELSE
maxlen=INT(WINDOW(w%)/10)
END IF
l1$=LEFT$(line1$,maxlen)
l2$=LEFT$(line2$,maxlen)
PRINT l1$
PRINT l2$
'Draw buttons
LINE (okx1,oky1)-(okx2,oky2),3,b
LINE (cnx1,cny1)-(cnx2,cny2),3,b
LOCATE 4,1
PRINT PTAB(okx1+8);"OK";
PRINT PTAB(cnx1+8);"Cancel"
'Check for box hit
ans%=dunno
WHILE ans%=dunno
WHILE MOUSE(0)=0
' wait for button press
WEND
m1=MOUSE(1): m2=MOUSE(2)
IF (m1>okx1 AND m1<okx2) AND (m2>oky1 AND m2<oky2) THEN
' OK box hit
ans%=true
LINE (okx1,oky1)-(okx2,oky2),2,bf
END IF
IF (m1>cnx1 AND m1<cnx2) AND (m2>cny1 AND m2<cny2) THEN
' Cancel box hit
ans%=false
LINE (cnx1,cny1)-(cnx2,cny2),2,bf
END IF
WEND
WHILE MOUSE(0)<>0
' wait for button release
WEND
WINDOW CLOSE w%
END SUB
'Test driver
LOCATE 20,1
PRINT "Testing 'req'..."
answer%=(0=0)
WHILE answer%
CALL req("This is a test of 'req'"," click either box",2,0,answer%)
IF answer% THEN
PRINT "'OK' clicked!"
ELSE
PRINT "'Cancel' clicked!"
END IF
WEND
END